package com.blt.car.me;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

import com.blt.car.R;
import com.blt.car.base.BaseCommonAdapter;
import com.blt.car.base.BaseFragment;
import com.blt.car.base.ViewHolder;
import com.blt.car.utils.StringUtils;

import java.util.ArrayList;
import java.util.List;

import blt.app_core.api.base.CoreEvent;
import blt.app_core.api.base.CoreManager;
import blt.app_core.api.other.OutApi;
import blt.app_core.api.other.bean.FeedBackVo;

/**
 * Created by xgp on 2017/6/13.
 */

public class FBTrackFragment extends BaseFragment implements View.OnClickListener {

    private BaseCommonAdapter mAdapter;
    private ListView lvFBTrack;
    private ArrayList<FeedBackVo> test;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_fb_track;
    }

    @Override
    protected void initData() {
        super.initData();
        CoreManager.getCore(OutApi.class).getFeedbackList(1, 10);
    }

    @Override
    protected void initView(ViewHolder holder) {
        lvFBTrack = holder.get(R.id.lv_fb_track);
        test = new ArrayList<>();
//        test.add("A");
//        test.add("B");
//        test.add("C");
//        test.add("D");

        lvFBTrack.setAdapter(mAdapter = new BaseCommonAdapter<FeedBackVo>(getContext(), test, R.layout.item_fbtrack) {
            @Override
            public void showView(int position, View convertView, ViewGroup parent) {
                TextView status = (TextView) convertView.findViewById(R.id.item_fbtrack_status);
                TextView content = (TextView) convertView.findViewById(R.id.fbtrack_context);
                TextView day = (TextView) convertView.findViewById(R.id.fbtrack_time);


                FeedBackVo vo = getItem(position);
                content.setText(vo.issue);
                if (vo.feedbackStatus == 0) {
                    status.setText("未处理");
                } else {
                    status.setText("已处理");
                }
                day.setText(StringUtils.getDay(vo.createTime));
            }
        });
    }

    @CoreEvent(coreClientClass = OutApi.class)
    public void onFeedbackList(List<FeedBackVo> data) {
        mAdapter.addAll(data);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {

        }
    }
}
